// pages/patient_index/patient_index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    followList:[
      {name:'随访问卷',img:'/hyb_yl/huanzhe/images/sf_index_wj.png',url:'/hyb_yl/huanzhe/pages/questionnaire/questionnaire'},
      {name:'随访宣教',img:'/hyb_yl/huanzhe/images/sf_index_xj.png',url:''},
      {name:'随访计划',img:'/hyb_yl/huanzhe/images/sf_index_jh.png',url:''},
      {name:'申请记录',img:'/hyb_yl/huanzhe/images/sf_index_jl.png',url:''},
      {name:'随访包',img:'/hyb_yl/huanzhe/images/sf_index_sfb.png',url:'/hyb_yl/huanzhe/pages/private_services/private_services'},
    ],
    tablist:["血压","血糖","体重","体温","服药"],
    tabIndex:0,
    animationData:{},//圆形进图条动画
    fuyaolist:[
      {value: 'USA', name: '阿司匹林肠溶片'},
      {value: 'USA', name: '阿司匹林肠溶片'},
      {value: 'USA', name: '阿司匹林肠溶片'},
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    // 随访计划完成进度
    setTimeout(()=>{
      var animation = wx.createAnimation({
        duration:500,
        timingFunction:'ease',
      })
      this.animation = animation
      animation.rotate(3/6*360).step()    //圆形进度占比
      this.setData({
        animationData:animation.export()
      })
    },1000)
    var j_id = options.j_id;
    that.setData({
      j_id:j_id
    })
  },
  // 随访问卷等
  bindfollow(e){
    var url = e.currentTarget.dataset.url
    console.log("随访链接",url)
    wx.navigateTo({
      url: url,
    })
  },
  // 切换就诊人
  bindswitch(e){
    
  },
  onShow:function(){
    var that = this;
    that.getUser();
  },
  // 获取用户信息
  getUser:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/follow.user_detail",
      data:{
        j_id:that.data.j_id
      },
      success:function(res)
      {
        that.setData({
          info:res.data
        })
      }
    })
  },
  //tab切换
  bindtab(e){
    this.setData({
      tabIndex:e.target.dataset.index
    })
  },
  // 测量
  bindadd(e){
    console.log("测量",e)
    var type = e.currentTarget.dataset.index
    // if(type==0){    //测量血压
      wx.navigateTo({
        url: '/pages/test_data/test_data',
      })
    // }else if(type==1){    //测量血糖
      
    // }else if(type==2){    //测量体重

    // }else if(type==3){    //测量体温
    
    // }else if(type==4){    //添加服药
      
    // }
  },
  // 查看历史数据
  bindhistory(e){
    wx.navigateTo({
      url: '/pages/history_data/history_data',
    })
  },
  // 查看完整计划
  bindplan(e){
    wx.navigateTo({
      url: '/pages/all_plan/all_plan',
    })
  },
  // 查看详情
  binddetail(e){
    wx.navigateTo({
      url: '/pages/plan_detail/plan_detail',
    })
  },
  // 查看原图
  bindchakan(e){

  },
  // 咨询医生
  bindzixun(e){
    wx.navigateTo({
      url: '/hyb_yl/czhuanjiasubpages/pages/zhuanjiazhuye/zhuanjiazhuye?zid='+this.data.zid,
    })
  },
  // 提交随访
  bindsubmit(e){
    wx.navigateTo({
      url: '/hyb_yl/',
    })
  },
})